import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)
const store = new Vuex.Store({
  state: {
    // dev 开发 | test 测试
    env: 'test',
    authorization: '',
    role: '',
    visitingArea: {
      nowArea: '',
      AreaList: '',
    },
    destroyId: '',
    approvalManagementTabs: 0,
    homepageTabs: 0,
    approvalSelector: {
      iInitiated: [0, 0],
      myApproval: 0,
    },
  },
  mutations: {
    initUserInfo(state, userInfo) {
      Vue.set(state, 'userInfo', userInfo)
    },
    deleteUserInfo(state) {
      Vue.delete(state, 'userInfo')
    },
    initPostInfo(state, postInfo) {
      Vue.set(state, 'postInfo', postInfo)
    },
    deletePostInfo(state) {
      Vue.delete(state, 'postInfo')
    },
    initAuthorization(state, data) {
      state.authorization = data
    },
    deleteAuthorizatio(state) {
      state.authorization = ''
    },
    initRole(state, data) {
      state.role = data
    },
    deleteRole(state) {
      state.role = ''
    },
    initVisitingArea(state, data) {
      state.visitingArea.AreaList = data
    },
    changeNowVisitingArea(state, data) {
      state.visitingArea.nowArea = data
    },
    deleteVisitingArea(state) {
      state.visitingArea = {
        nowArea: '',
        AreaList: '',
      }
    },
    initDestroyId(state, data) {
      state.destroyId = data
    },
    deleteDestroyId(state) {
      state.destroyId = ''
    },
    initApprovalManagementTabs(state, data) {
      state.approvalManagementTabs = data
    },
    deleteApprovalManagementTabs(state) {
      state.approvalManagementTabs = 0
    },
    initHomepageTabs(state, data) {
      state.homepageTabs = data
    },
    deleteHomepageTabs(state) {
      state.homepageTabs = 0
    },
    initApprovalSelectorIInitiated(state, data) {
      state.approvalSelector.iInitiated = data
    },
    initApprovalSelectorMyApproval(state, data) {
      state.approvalSelector.myApproval = data
    },
    deleteApprovalSelector(state) {
      state.approvalSelector = {
        iInitiated: [0, 0],
        myApproval: 0,
      }
    },
  },
})
export default store
